package cn.bigcontainer.alt.meta.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.multipart.MultipartFile;

import cn.bigcontainer.alt.common.util.BigConstant;
import cn.bigcontainer.alt.meta.dto.MFileDto;
import cn.bigcontainer.alt.meta.service.MFileService;

@Controller
@RequestMapping("/meta/ckeditor")
@SessionAttributes(BigConstant.SESSION_USER)
public class CKEditorController {

	@Resource
	private MFileService fileService;

	@RequestMapping("/upload")
	public String upload(MultipartFile upload, @RequestParam Map<String, Object> req, Map<String, Object> map) {
		MFileDto fileDto = fileService.upload(upload, req);
		map.putAll(req);
		map.put("file", fileDto);
		return "meta/ckeditor/upload";
	}

}
